home *** CD-ROM | disk | FTP | other *** search
- /* FILE: PStrDraw.c
- Draws 1 to 10 Pascal strings at specified locations in the
- current GrafPort. It Offers auto-centering and New-Line modes.
- If h == 0 then it uses the last (current) h position.
- If v == 0 then it uses the last (current) v position.
- If x < 0 then s is centered inside the portRect. If y < 0 then
- then it offsets -y number of lines from current v pos.
- Otherwise, h and v represent the desired x and y coordinates. */
- #include "PStrLib.h"
-
- PStrDraw(count, s, h, v)
- int count; /* number of { s, h, v} sets to follow */
- char *s; /* a pascal string to draw */
- int h; /* horizontal position */
- int v; /* vertical position */
- {
- register char *argPtr = (char *)&count;
- register char *sp;
- register Rect *rp = &thePort->portRect;
- register int x, y, lineHeight = 1.5 * thePort->txSize;
- static int old_x = 0, old_y = 0;
-
- while (--count >= 0) {
- sp = *(char **)(argPtr += 2);
- x = *(int *)(argPtr += 4);
- y = *(int *)(argPtr += 2);
- if (x >= 0)
- old_x = x;
- else if (x != CUR) /* Auto-Center Mode? */
- old_x = (rp->right - rp->left - StringWidth(sp)) / 2;
- if (y >= 0)
- old_y = y;
- else if (y != CUR) /* New-Line Mode? */
- old_y += -y * lineHeight;
- MoveTo(old_x, old_y);
- DrawString(sp);
- old_x += StringWidth(sp);
- }
- }